package controller;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import service.TeacherCheckService;

@CrossOrigin(originPatterns="*",allowCredentials="true")
@Controller
@RequestMapping("teachercheck")
public class TeacherCheck {
	@Autowired
	private TeacherCheckService teachercheckservice;
	@GetMapping("currentsingle")
	@ResponseBody
	public List<Map<String,Object>> teachercheckcurrent(String cid){
		List<Map<String,Object>> result =teachercheckservice.getinfo1(cid);
		//根据cid从课程表里取出选了这门课的学生的uid和uname
		//根据uid从checkinfo表中取出上课情况，求平均值
		//返回uid,uname,上课情况平均值给前端
		//System.out.print(teachercheckservice.getinfo(cid));
		return result;
	}
	@GetMapping("currentall")
	@ResponseBody
	public double teachercheckcurrentall(String cid){
		double result =teachercheckservice.getcheckinfo(cid);
		//根据cid从课程表里取出选了这门课的学生的uid和uname
		//根据uid从checkinfo表中取出上课情况，求平均值
		//返回uid,uname,上课情况平均值给前端
		//System.out.print(teachercheckservice.getinfo(cid));
		return result;
	}
	@GetMapping("final")
	@ResponseBody
	public List<Map<String,Object>> teachercheckfinal(String cid){
		List<Map<String,Object>> result =teachercheckservice.getcheckinfo1(cid);
		//根据cid从课程表里取出选了这门课的学生的uid和uname
		//根据uid从checkinfo表中取出上课情况，求平均值
		//返回uid,uname,上课情况平均值给前端
		//System.out.print(teachercheckservice.getinfo(cid));
		return result;
	}
}
